﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using System.Configuration;

namespace FONCREAGROINTEGRAL.Reporting.RRHH
{
    public partial class CrystalCertificadoCTS : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
            //var data = entidades.RHCertificadoCTS(10, 3);
            //var iConnectionInfo As ConnectionInfo = New ConnectionInfo()
            string IdEjercicioMes = Convert.ToString(Request.QueryString["IdEjercicioMes"]);
            string IdTipoTrabajador = Convert.ToString(Request.QueryString["IdTipoTrabajador"]);

            string Servidor = ConfigurationManager.AppSettings["Servidor"].ToString();
            string DataBase = ConfigurationManager.AppSettings["DataBase"].ToString();
            string User = ConfigurationManager.AppSettings["User"].ToString();
            string Clave = ConfigurationManager.AppSettings["Clave"].ToString();

            var reporte = new ReportDocument();
            var cadena = Server.MapPath("../Crystal/CertificadoCTS.rpt");
            reporte.Load(cadena);

            //var data = new da
            //repo reportDataSource = new ReportDataSource("RPlanillaAreas", entidades.RPlanillaAreas(id, id1).ToList());

            //CrystalReportSource1
            //reporte.SetDataSource(entidades.);
            //reporte.SetDataSource(entidades.RHCertificadoCTS(10, 3));
            reporte.SetParameterValue("@IdEjercicioMes", IdEjercicioMes);
            reporte.SetParameterValue("@IdTipoTrabajador", IdTipoTrabajador);
            reporte.DataSourceConnections[0].SetConnection(Servidor, DataBase,User,Clave);
            
            //reporte.DataSourceConnections[0].SetLogon(User, Clave);
            //reporte.DataSourceConnections[0].IntegratedSecurity(true);
            //reporte.DataSourceConnections[0].SetLogon(User, Clave);

            CrystalReportViewer1.ReportSource = reporte;

            //}
        }
    }
}